<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>
    <input class="like" type="checkbox">足球
    <input class="like" type="checkbox">篮球
    <input class="like" type="checkbox">排球
    <input class="like" type="checkbox">乒乓球<br>
    <input id="all" type="checkbox">全选</input>
    <script>
         var inputs = document.querySelectorAll(".like");
         var all = document.querySelector("#all")
         console.log(inputs)
         all.onclick = function(){
            for(var i =0;i<inputs.length;i++){
                inputs[i].checked = true;
            }
         }
          for(var i =0;i<inputs.length;i++){
             inputs[i].onclick = function(){
                var flag = true; 
                for(var j =0 ;j<inputs.length;j++){
                    if(inputs[j].checked == false){
                        flag = false;
                        break;
                    }
                } 
                 all.checked = flag;
            }
         }
  
    </script>
</body>
</html>